stylecontext: Do not have a default style
authorBenjamin Otte <otte@redhat.com>
Wed, 4 Feb 2015 17:26:32 +0000 (18:26 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 4 Feb 2015 17:36:11 +0000 (18:36 +0100)
A bunch of applications expect the style to be as close to the actual
style as possible even during creation of the widget. Try to accomodate
these apps.

This reverses the effects of 27285f1f0fb00bb4507a8bf3e426bef940ae41af

https://bugzilla.gnome.org/show_bug.cgi?id=743395
https://bugzilla.redhat.com/show_bug.cgi?id=1185999

gtk/gtkstylecontext.c

index 523ed8814cfdfb3b1ea102780142799af9a3debc..941410f9a85e93b66c76c482e8ea78e86e57f772 100644 (file)
@@ -420,7 +420,6 @@ gtk_style_context_init (GtkStyleContext *style_context)
   /* Create default info store */
   priv->cssnode = gtk_css_node_new ();
   gtk_css_node_declaration_set_state (&priv->cssnode->decl, GTK_STATE_FLAG_DIR_LTR);
-  priv->cssnode->values = g_object_ref (gtk_css_static_style_get_default ());
 
   priv->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue));
 
@@ -881,8 +880,6 @@ gtk_style_context_lookup_style (GtkStyleContext *context)
   if (cssnode->values)
     return cssnode->values;
 
-  g_assert (gtk_style_context_is_saved (context));
-
   values = g_hash_table_lookup (priv->style_values, cssnode->decl);
   if (values)
     {
@@ -2978,7 +2975,10 @@ _gtk_style_context_validate (GtkStyleContext  *context,
   priv->pending_changes = 0;
   gtk_style_context_set_invalid (context, FALSE);
 
-  current = g_object_ref (cssnode->values);
+  current = cssnode->values;
+  if (current == NULL)
+    current = gtk_css_static_style_get_default ();
+  g_object_ref (current);
 
   /* Try to avoid invalidating if we can */
   if (gtk_style_context_style_needs_full_revalidate (current, change))